package part10.controller;

/**
 * @author wcj
 * @Date 2021/5/19 19:34
 * @Version 1.0
 */
public abstract class BaseEvent {

    private long eventTime;

    /**
     * final修饰的成员变量必须要直接初始化或者在构造器中进行初始化，因为其值不能再改变
     */
    protected final long delayTime;

    public BaseEvent(long delayTime) {
        this.delayTime = delayTime;
    }

    public void start() {
        this.eventTime = System.nanoTime() + delayTime;
    }

    public boolean ready() {
        return System.nanoTime() >= eventTime;
    }

    /**
     * 抽象函数
     */
    public abstract void action();
}
